from django.shortcuts import render

# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render
import json
from mqttApi import mqttManage

def hello(request):
    return HttpResponse("你好田小花")

def index(request):
    return render(request,"index.html")

def setTime(request):
    return render(request,"fff.html")

def postApi(request):
    # 协议
    if request.method == 'POST':
        print("检测到了POST请求")
        JsonProtocol = [{ "verision" : 1.0 , "userID":10000 , "userPassword": 12345 , "PostKey": 1 , "userPicture" : "none"}]
        # return HttpResponse(json.dumps(JsonProtocol)) #以字符串作为内容的HTTP响应类。可以读取、追加或替换此内容。
        #concat = request.POST
        postBody = request.body
        #print(concat)
        #print(type(postBody))
        #print(postBody)
        json_result = json.loads(postBody)
        print(type(json_result))


        return HttpResponse(JsonProtocol)
